<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>endpwent</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_003_214">&nbsp;</a>NAME</h4><blockquote>
endpwent, getpwent, setpwent - user database functions
</blockquote><h4><a name = "tag_000_003_215">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="pwd.h.html">pwd.h</a>&gt;

void endpwent(void);
struct passwd *getpwent(void);
void setpwent(void);
</code>
</pre>
</blockquote><h4><a name = "tag_000_003_216">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i><a href="getpwent.html">getpwent()</a></i>
function returns a pointer to a structure containing the broken-out fields of
an entry in the user database.  Each entry in the user database contains a
<b>passwd</b> structure.  When first called,
<i><a href="getpwent.html">getpwent()</a></i>
returns a pointer to a <b>passwd</b> structure containing the first entry in
the user database.  Thereafter, it returns a pointer to a <b>passwd</b>
structure containing the next entry in the user database.  Successive calls
can be used to search the entire user database.
<p>
If an end-of-file or an error is encountered on reading,
<i><a href="getpwent.html">getpwent()</a></i>
returns a null pointer.
<p>
The
<i><a href="setpwent.html">setpwent()</a></i>
function effectively rewinds the user database to allow repeated searches.
<p>
The
<i>endpwent()</i>
function may be called to close the user database when processing is complete.
<p>
These interfaces need not be reentrant.
</blockquote><h4><a name = "tag_000_003_217">&nbsp;</a>RETURN VALUE</h4><blockquote>
The
<i><a href="getpwent.html">getpwent()</a></i>
function returns a null pointer on end-of-file or error.
</blockquote><h4><a name = "tag_000_003_218">&nbsp;</a>ERRORS</h4><blockquote>
The
<i><a href="getpwent.html">getpwent()</a></i>,
<i><a href="setpwent.html">setpwent()</a></i>
and
<i>endpwent()</i>
functions may fail if:
<dl compact>

<dt>[EIO]<dd>
An I/O error has occurred.

</dl>
<p>
In addition,
<i><a href="getpwent.html">getpwent()</a></i>
and
<i><a href="setpwent.html">setpwent()</a></i>
may fail if:
<dl compact>

<dt>[EMFILE]<dd>
{OPEN_MAX} file descriptors are currently open in the calling process.

<dt>[ENFILE]<dd>
The maximum allowable number of files is currently open in the system.

</dl>
<p>
The return value may point to a static area which is overwritten
by a subsequent call to
<i><a href="getpwuid.html">getpwuid()</a></i>,
<i><a href="getpwnam.html">getpwnam()</a></i>
or
<i><a href="getpwent.html">getpwent()</a></i>.
</blockquote><h4><a name = "tag_000_003_219">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_003_220">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
These functions are provided due to their historical usage.  Applications
should avoid dependencies on fields in the password database, whether the
database is a single file, or where in the filesystem namespace the database
resides.  Applications should use
<i><a href="getpwuid.html">getpwuid()</a></i>
whenever possible both because it avoids these dependencies and for greater
portability with systems that conform to earlier versions of this
specification.
</blockquote><h4><a name = "tag_000_003_221">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_003_222">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="endgrent.html">endgrent()</a></i>,
<i><a href="getlogin.html">getlogin()</a></i>,
<i><a href="getpwnam.html">getpwnam()</a></i>,
<i><a href="getpwuid.html">getpwuid()</a></i>,
<i><a href="pwd.h.html">&lt;pwd.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
